package com.biz.storage.service;

import com.biz.storage.adapter.*;
import org.springframework.stereotype.*;
import org.springframework.web.multipart.*;

import java.io.*;
import java.util.*;

/**
 * @Description
 *      文件处理
 * @Author liuxi
 * @Date 2024/4/26
 **/
@Service
public class FileService {

    private final StorageAdapter storageService;

    public FileService(StorageAdapter storageService) {
        this.storageService = storageService;
    }

    /**
     * 上传文件
     */
    public void upload(MultipartFile uploadFile, String bucket, String objectName) {
        try {
            storageService.uploadFile(uploadFile, bucket, objectName);
        } catch (IOException e) {
            throw new RuntimeException("上传文件失败");
        }
    }

}
